package com.qyhl.shop.shop.center.coupon.detail;

import com.qyhl.shop.common.ShopUrl;
import com.qyhl.webtv.basiclib.utils.network.EasyHttp;
import com.qyhl.webtv.basiclib.utils.network.callback.SimpleCallBack;
import com.qyhl.webtv.basiclib.utils.network.exception.ApiException;
import com.qyhl.webtv.commonlib.common.CommonUtils;
import com.qyhl.webtv.commonlib.entity.shop.ShopCouponBean;

public class ShopCenterCouponDetailModel implements ShopCenterCouponDetailContract.ShopCenterCouponDetailModel {
    private ShopCenterCouponDetailPresenter mPresenter;

    public ShopCenterCouponDetailModel(ShopCenterCouponDetailPresenter mPresenter) {
        this.mPresenter = mPresenter;
    }

    @Override
    public void getDetail(String phoneNum, int userCouponId) {
        EasyHttp.post(ShopUrl.SHOP_CENTER_COUPON_DETAIL)
                .params("siteId", CommonUtils.getInstance().getSite() + "")
                .params("phoneNum", phoneNum)
                .params("userCouponId", userCouponId + "")
                .execute(new SimpleCallBack<ShopCouponBean>() {
                    @Override
                    public void onError(ApiException e) {
                        mPresenter.setError("获取优惠券详情失败！");
                    }

                    @Override
                    public void onSuccess(ShopCouponBean bean) {
                        mPresenter.setDetail(bean);
                    }
                });
    }
}
